Figure (Distance Formula) shows a simple derivation for
a formula that lets us calculate the distance between two points.
In the figure we see that the horizontal and vertical sides of the
right triangle are labeled with their magnitude. For example,
the horizontal side has magnitude , as can be seen by
observing the point values for the two points and
One just makes a right triangle from the two points
of the line and uses the Pythagorean relation for the hypotenuse.
. The distance between two points,
P & Q can be calculated by making a right triangle from the two points
and noting that the side lengths are known. From the Pythagorean theorem,
the hypotenuse length is also known and it is the distance between
the two points. Unless symbolic algebra is needed, we use
to obtain values and let computers do the work.
In all of the popular computer algebra systems (Matlab, Mathematica,
Maple, Maxima, SAGE, Geogebra), the absolute value function applied
to a direction vector will return the magnitude of the vector. Why
would that be? Consider that the magnitude of a real number can be
described as the square root of itself squared. Equation 1 is One definition
of absolute value with a scaler.
It may be a little confusing, but the square root symbol, ,
always refers to only the principle square root, i.e. a positive real
number. If one has an equation, such as , then ,
again implying that the square root symbol yields only the principle
square root.
In the complex plane, the magnitude of a number is the distance of the point from the
origin when graphed as the complex part on one axis and the real part
on the other axis. Thus the distance formula would give its distance
from the origin which is called its magnitude or modulus.
This magnitude is then extended to vector space in general and the
absolute value function for a Euclidean vector is defined as the distance
formula to give the magnitude. In vector space, the notation is often
given as double vertical lines. In Eq we express the absolute value of a vector
enclosed by double vertical lines using the definition from equation
. You may not find it obvious that the absolute value
of a vector is equal to the square root of the sum of its squared
elements! Equation follows from a
We define
as the distance of a point from the zero origin. In vector space,
having as many dimensions as the vector has elements, the vector describes
a point location. The distance of that point from the origin is given
by . The difference between and is not really a change in definition, but rather
the extension of the definition from 1-dimension to many dimensions.
Eq is called the
For exactly two dimensions the distance from the origin is
and the distance between two point, and
is
On a Cartesian coordinate system in 2 dimensions, absolute value is
also the distance of a point from the origin. If one obtains
the absolute value of the difference between two points, the subtraction
is performed first and then the distance from the origin for the result
is presented as the absolute value. Said more simply, the distance
between two points is the absolute value of the points when treated
as vectors. Still another way to express the same is that the distance
between two points is the magnitude of their direction vector.
Example 1 Let and . Find the distance between
these two 2-d points using the relationship of equation Eq .
Answer: The distance will be
In programming code, the absolute value function performs the distance
formula calculation on any pair of tuples. Look at the abs(P) function
here.
Code for line segment length in Sage. We define two numbers and put them into a
vector. It originates at Taking the absolute value then yields the line length. The result is . If one applies the distance formula then
it is obvious that the vector length is correct.
=
If we were using a computer algebra
system, we would be done by typing in
or and the machine will return the distance between the
points. Of course by the definition, this works for all vector spaces
(i.e. all dimensions).